<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/6/24
 * Time: 18:38
 */

namespace app\api\controller\v2\controller\SMS;

use think\Controller;
use app\api\controller\v2\ali_Sms as SS;

class SMS extends Controller
{
    private $ali = '';
    /**
     * 构造方法
     * SMS constructor.
     */
    public function __construct(){
        if($this->ali == '')
        {
            $this->ali = SS::getInstance();
        }
    }
    /**
     * 发送验证码
     * @param $phone
     */
    public function send_sms($phone = null)
    {
        if($phone == null)
        {
            return $this->result(false, 400, '参数错误');
        }
        $result = $this->ali->sendSMS($phone);
        return $this->result($result['data'], $result['code'], $result['msg']);
    }

    /**
     * 校验短信验证码
     * @param $phone
     * @param $code
     */
    public function check_sms($phone = null, $code = null)
    {
        $result = $this->ali->checkValidPhone($phone, $code);
        return $this->result($result['data'], $result['code'], $result['msg']);
    }
}